package com.bootdo.common.utils.orm;

import java.util.List;

public class CommonPage<T> {
    private Long totalRows;
    private Integer pageSize=10;
    private Integer pageNumber=1;
    private List<T> data;

    public CommonPage() {
    }

    public CommonPage(Integer pageNumber, Integer pageSize){
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
    }

    public void check(){
        if(null==pageSize || pageSize <1)
            pageSize = 10;

        if(null==pageNumber || pageNumber <1)
            pageNumber = 1;
    }

    public Long getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(Long totalRows) {
        this.totalRows = totalRows;
    }

    public Integer getPageSize() {
        return null == this.pageSize?Integer.valueOf(20):this.pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageNumber() {
        return null == this.pageNumber?Integer.valueOf(1):this.pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public List<T> getData() {
        return this.data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public boolean isNotEmpty() {
        return null != this.data && this.data.size() > 0;
    }
}